import Vue from 'vue'
import App from '../App'
import Router from 'vue-router'

const forget = r => require.ensure([], () => r(require('../page/forget/forget')), 'forget')
const shopDetail = r => require.ensure([], () => r(require('../page/shop/children/shopDetail')), 'shopDetail')

const demo = r => require.ensure([], () => r(require('../page/demo/demo')), 'demo')
const home = r => require.ensure([], () => r(require('../page/home/home')), 'home')
const city = r => require.ensure([], () => r(require('../page/city/city')), 'city')
const msite = r => require.ensure([], () => r(require('../page/msite/msite')), 'msite')
const shop = r => require.ensure([], () => r(require('../page/shop/shop')), 'shop')
const search = r => require.ensure([], () => r(require('../page/search/search')), 'search')
const order = r => require.ensure([], () => r(require('../page/order/order')), 'order')
const food = r => require.ensure([], () => r(require('../page/food/food')), 'food')
const user = r => require.ensure([], () => r(require('../page/user/user')), 'user')
const info = r => require.ensure([], () => r(require('../page/user/children/info')), 'info')
const updateUserName = r => require.ensure([], () => r(require('../page/user/children/children/updateUserName')), 'updateUserName')
const address = r => require.ensure([], () => r(require('../page/user/children/children/address')), 'address')
const add = r => require.ensure([], () => r(require('../page/user/children/children/children/add')), 'add')
const tocity = r => require.ensure([], () => r(require('../page/user/children/children/children/children/city')), 'tocity')
const balance = r => require.ensure([], () => r(require('../page/balance/balance')), 'balance')
const balancedetail = r => require.ensure([], () => r(require('../page/balance/children/balancedetail')), 'balancedetail')
const points = r => require.ensure([], () => r(require('../page/points/points')), 'points')
const pointsdetail = r => require.ensure([], () => r(require('../page/points/children/pointsdetail')), 'pointsdetail')
const benefit = r => require.ensure([], () => r(require('../page/benefit/benefit')), 'benefit')
const login = r => require.ensure([], () => r(require('../page/login/login')), 'login')

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      component: App,
      children: [
        //二选一 start
        {
          path: '/',
          redirect : '/home'
        },
        // {
        //   path : '',
        //   redirect : '/home'
        // },
        //二选一 end
        {
          path : 'demo',
          component : demo
        },
        {
          path : 'home',
          component : home
        },
        {
          path : 'city',
          component : city
        },
        {
          path : 'msite',
          component : msite
        },
        {
          path : 'shop',
          component : shop,
          children:[
            
            {
              path : 'shopDetail',
              component: shopDetail
            }
          ]
        },
        {
          path: 'forget',
          component: forget,
        },
        {
          path : 'food',
          component : food
        },
        {
          path : 'user',
          component: user,
          children: [
            {
              path : 'info',
              component: info,
              children: [
                {
                  path: 'updateUser',
                  component: updateUserName,
                },
                {
                  path: 'address',
                  component: address,
                  children: [
                    {
                      path: 'add',
                      component: add,
                      children: [
                        {
                          path: 'tocity',
                          component: tocity,
                        }
                      ]
                    }
                  ]
                },
              ]
            },

          ]
        },
        {
          path : 'balance',
          component: balance,
          children:[
            {
              path : 'detail',
              component : balancedetail
            },
          ]
        },
        {
          path : 'points',
          component: points,
          children:[
            {
              path : 'detail',
              component : pointsdetail
            },
          ]
        },
        {
          path : 'benefit',
          component: benefit,

        },
        {
          path : 'order',
          component: order,

        },
        {
          path : 'search',
          component : search
        },
        {
          path : 'login',
          component : login
        },
      ]
    }
  ]
})
